package com.schoolMall.utils;

import com.google.code.kaptcha.Constants;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * @author:zyh
 * @Time:2021-08-30-17:16
 * @email:1269231889@qq.com
 */
public class CodeUtil {
    public static boolean checkVerifyCode(HttpServletRequest request) {
        String attribute = (String) request.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY);
        String verifyCode = HttpServletRequestUtil.getString(request, "verifyCode");
        if (Objects.nonNull(verifyCode)) {
            return attribute.equals(verifyCode);
        }
        return false;
    }
}
